﻿using System.Collections.Generic;
using System.Windows.Media;
using Balder.Core;
using Balder.Core.Math;
using Matrix = Balder.Core.Math.Matrix;
using System.Windows;
using System.Windows.Input;
using Balder.Core.Execution;
using Balder.Core.Objects.Geometries;

using Balder.Core.Objects.Flat;

namespace Studio
{
	public class MyGame : Game
	{
	    public MyGame()
	    {
	        
	    }

		private Mesh _audi;
        private Sprite _sprite1;
        private Sprite _sprite2;
        private float _audiTranslation;
	    private float _audiRotation;
		public override void OnInitialize()
		{
			// We set the background color for the display to black
			Display.BackgroundColor = Colors.Black;
			base.OnInitialize();
		}

		public override void OnLoadContent()
		{
			// Load the audi asset found in the assets folder.
			// One does not need to add the assets folder in the path, as this is implicit
			// All assets must be of type resource in the properties window in Visual Studio
            Width = 700;
            Height = 700;

            _sprite2 = ContentManager.Load<Sprite>("Sky.png");
            _sprite2.Position = new Balder.Core.Math.Coordinate(5, 5, 5);
            _sprite2.Width = 100;
            _sprite2.Height = 100;
           
            _sprite1 = ContentManager.Load<Sprite>("gothic_cherry.png");
            _sprite1.Position = new Balder.Core.Math.Coordinate(30, 30, 30);
            _sprite1.Width = 10;
            _sprite1.Height = 10;

            _audi = ContentManager.Load<Mesh>("audi.ASE");
            _audi.Position = new Coordinate(20, 20, 20);
            Scene.AddNode(_audi);

            #region Fady
            //_audi = ContentManager.Load<Mesh>("audi.ASE");
            //Scene.AddNode(_audi);
            #endregion

            //Scene.AddNode(_sprite1);
            //Scene.AddNode(_sprite2);
            //_audi.CreateRotation(90, Axis.Y);

			// Set the camera to point at the Zero location in 3D space and its position to be a
			// bit from the car itself
			Camera.Target = Vector.Zero;
			Camera.Position = new Vector(0,0,-10);

			base.OnLoadContent();
		}

		// The update method is called every frame
		public override void OnUpdate()
		{
            //_audi.CreateTranslation(_audiTranslation, Axis.X);
            //_audiTranslation += .0004f;
            //_audi.CreateRotation(90, Axis.Y);
            //_audi.CreateScale(.1f);
            _audi.World = Matrix.CreateRotationY(_audiRotation);
            _audiRotation += 0.5f;
			base.OnUpdate();
		}
	}
}
